﻿$(function () {
    $("#fileData").uploadify({
        'multi': false,
        'buttonText': 'Upload Image',
        'buttonClass': 'btn btn-choose-file',
        'width': 98,
        'height': 35,
        'fileSizeLimit': '100KB',
        'swf': '/images/uploadify.swf',
        'fileTypeDesc': 'Flash',
        'fileTypeExts': '*.jpg; *.png; *.gif',
        'uploader': '/MyAccount/ProductList/Upload',
        'onUploadProgress': function (file) {
            // Disabler
            openProcess();
        },
        'onUploadError': function(file, errorCode, errorMsg, errorString) {
            console.log('The file ' + file.name + ' could not be uploaded: ' + errorString);
        } ,
        'successTimeout': 60,
        'onUploadSuccess': function (file, data, response) {
            hideProcess();
            var model = jQuery.parseJSON(data);
            if (model != undefined && model != null) {
                viewModel.ImagePath(model.FilePath);
                viewModel.ImageName(model.FileName);
            }
        }
    });
});

$(function () {
    // First file
    $("#fileAttach").uploadify({
        'multi': false,
        'buttonText': 'Upload File Attach',
        'buttonClass': 'btn btn-choose-file',
        'width': 98,
        'height': 35,
        'fileSizeLimit': '10240KB',
        'swf': '/images/uploadify.swf',
        'fileTypeDesc': 'Images',
        'fileTypeExts': '*.xls; *.xlsx; *.doc; *.docx; *.pdf; *.ppt; *.pptx; *.rtf; *.txt',
        'uploader': '/MyAccount/ProductList/UploadAttach',
        'onUploadProgress': function (file) {
            openProcess();
        },
        'successTimeout': 180,
        'onUploadSuccess': function (file, data, response) {
            hideProcess();
            var model = jQuery.parseJSON(data);
            viewModel.OriginalAttachName(model.OriginalAttachName);
            viewModel.AttachName(model.AttachName);
            viewModel.AttachType(model.AttachType);
        }
    });

});
